package Client;


import javax.swing.JOptionPane;

public class GribonnsAPI {
	public void msg(String... ss) {
		for (String s : ss) {
			if (!s.equals(""))
				JOptionPane.showMessageDialog(null, s, "Info", JOptionPane.INFORMATION_MESSAGE);
		}
	}
	public void sleep(int ms){
		try {
			Thread.currentThread();
			Thread.sleep(ms);
		} catch (InterruptedException e1) {
			e1.printStackTrace();
		}
	}
	public void alert(String... ss) {
		for (String s : ss) {
			if (!s.equals(""))
				JOptionPane.showMessageDialog(null, s, "Error", JOptionPane.ERROR_MESSAGE);
		}
	}
	public boolean isNumeric(String s) {
		char[] sLetters = s.toCharArray();
		char[] numbers = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.' };
		for (char c : sLetters) {
			boolean isTrue = false;
			for (char n : numbers) {
				if (c == n) {
					isTrue = true;
				}
			}
			if (!isTrue)
				return false;
		}
		return true;
	}
	public int toInt(String s) {
		if (s.equals("")) {
			return 0;
		}
		return Integer.parseInt(s);
	}

	public Double toDouble(String s) {
		if (s.equals("")) {
			return 0.0;
		}
		return Double.parseDouble(s);
	}

	public String intToString(Integer i) {
		if (i == null) {
			return "";
		}
		return Integer.toString(i);
	}

	public String doubleToString(Double d) {
		if (d == null) {
			return "";
		}
		return Double.toString(d);
	}

	public String clear(String s) {
		if (s.equals("")) {
			return s;
		}
		return s.replace(" ", "");
	}

	public String replaceDots(String s) {
		if (s.equals("")) {
			return s;
		}
		return s.replace(".", ",");
	}

	public String replaceCommas(String s) {
		if (s.equals("")) {
			return s;
		}
		return s.replace(",", ".");
	}
}
